<!DOCTYPE html>
<html lang="en">
<head>
    <#include "/commonPage.html" />
</head>
<body class="easyui-layout">
<div data-options="region:'north',border:false" style="height:90px;">
    <div><h1 style="color:#133ad5">添加用户</h1></div>
    <div>
        <HR width="100%" color=#133ad5 SIZE=1>
    </div>
</div>
<div data-options="region:'center',border:false" style="padding:0">
    <form id="ff" method="post" style="width: 500px;margin: 0 auto;">
        <div style="margin-bottom:20px">
            <input id="userName" class="easyui-textbox" name="userName" style="width:100%"
                   data-options="label:'账号名:',labelPosition:'left',labelWidth:100,prompt:'输入账号名',required:true">
        </div>
        <div style="margin-bottom:20px">
            <input id="passWord" class="easyui-passwordbox" name="passWord" style="width:100%"
                   data-options="label:'账号密码:',labelPosition:'left',labelWidth:100,prompt:'输入账号密码',required:true">
        </div>
        <div style="margin-bottom:20px">
            <input id="rePassWord" class="easyui-passwordbox" style="width:100%"
                   data-options="label:'重复账号密码:',labelPosition:'left',labelWidth:100,prompt:'输入账号密码',required:true">
        </div>
        <div style="margin-bottom:20px">
            <label class="textbox-label textbox-label-left" for="mycombobox"
                   style="text-align: left; width: 100px; height: 30px; line-height: 30px;">权限级别:</label>
            <span class="textbox textbox-invalid easyui-fluid" style="width: 350px;">
                    <select id="mycombobox" class="easyui-combobox" name="authority" panelHeight="auto" required="true"
                            style="width: 350px; margin: 0px; padding-top: 0px; padding-bottom: 0px; height: 28px; line-height: 28px;">
                        <option value="1">员工</option>
                        <option value="0">管理员</option>
                    </select>
                </span>
        </div>
    </form>
    <div style="width: 500px;margin: 30px auto 0 auto;" align="center">
        <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)"
           onclick="addBusinessfunction()" style="width:80px;margin-right: 50px;">保存</a>
        <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)"
           onclick="cleartext()" style="width:80px">清除</a>
    </div>
    <script>
        function cleartext() {
            $('#ff').form('clear');
            $('#mycombobox').combobox('reload');
        };

        function addBusinessfunction() {
            $('#ff').form('submit', {
                url: '/user/userAdd',
                onSubmit: function () {
                    var isValid = $(this).form('validate');
                    if (!isValid) {
                        $.messager.progress('close');	// hide progress bar while the form is invalid
                    } else {
                        if ($('#rePassWord').val() != $('#passWord').val()) {
                            $.messager.alert('错误', '密码不一致', 'error');
                            return false;
                        }
                    }
                    return isValid;
                },
                success: function (data) {
                    if (data == "成功") {
                        $.messager.alert('Info', data, 'info');
                        //$('#ff').form('clear');
                    } else {
                        $.messager.alert('错误', data, 'error');
                    }
                }
            })
        };
    </script>
</div>
</body>
</html>